<template>
	<div class="roomInformation">
		<!-- <panel @add="addUser"></panel> -->
		<!-- <addAppointment :dialogFormVisible="showAddDialog" @closeDialog="showAddDialog=false" @refresh="refresh" :addTemp="{...addTemp}" :urlTemp="urlTemp"></addAppointment> -->
		<roomRateList :roomList="roomList" @refresh="refresh" class="list" @change="change($event); dialogFormVisible = true"></roomRateList>
		<el-pagination background layout="prev, pager, next" :total="total" :page-size="10" @current-change="handleCurrentChange" class="pagination"></el-pagination>
		<!-- <roomAppointmentUpdate :dialogFormVisible="dialogFormVisible" @closeDialog="dialogFormVisible = false" :toChangeRow="toChangeRow" @refresh="refresh"></roomAppointmentUpdate> -->

	</div>
</template>

<script>
	import roomRateList from "@/components/room/roomRateList";
	// import panel from "@/components/room/roomAddAppointment";
	// import roomAppointmentUpdate from "@/components/room/roomAppointmentUpdate";
	// import addAppointment from '@/components/room/addAppointment';
	export default {
		name: "roomInformation",
		data() {
			return {
				roomList: [],
				page_now: undefined,
				total: undefined,
				page_num: undefined,
				toChangeIndex: undefined,
				dialogFormVisible: false,
				showAddDialog: false,
				toChangeRow: null,
				searchVal: '',
				addTemp: {

				},
				urlTemp: {}
			};
		},
		components: {
			roomRateList,
			// panel,
			// roomAppointmentUpdate,
			// addAppointment
		},
		methods: {
			addUser: function() {
				this.showAddDialog = true;
				this.urlTemp = { ...this.urlTemp
				};
			},
			change: function(index) {
				console.log(index);
				this.toChangeRow = this.roomList[index];
			},
			handleCurrentChange: async function(val) {
				let data = await this._axios
					.get(`/ycw/rooms/getroomRateList?page=${val}`)
					.then(data => data.data.data);
				this.roomList = data.data;
			},
			
			refresh: async function() {
				let data = await this._axios
					.get("/ycw/rooms/getroomRateList")
					.then(data => data.data.data);
				this.roomList = data.data;
				this.page_now = data.page_now;
				this.total = data.page_total * data.page_num;
				this.page_num = data.page_num;
			}
		},
		mounted: async function() {
			this.refresh();
		}
	};
</script>

<style lang="scss" scoped>
	.pagination {
		margin-top: 10px;
	}

	.list {
		height: 60vh;
	}
</style>
